/*
 * myaffine.h
 *
 *  Created on: Jul 22, 2012
 *      Author: Nautilus
 */

#ifndef MYAFFINE_H_
#define MYAFFINE_H_

typedef struct tagPoint3D{
	float x, y, z;
}POINT3D;

typedef struct tagDoubleMatrix
{
	int nRow;
	int nCol;
	float *m;
} MATRIX;

// Perspective projection transformation matrix
float PPMatrix[4][4]={
		{1,  0,  0, 0},
		{0,  1,  0, 0},
		{0,  0,  1, 0},
		{0,  0,  1, 0}};


void initMatrix(MATRIX *);
void releaseMatrix(MATRIX *);

/*
 *  Calculate R = A * B
 * */
unsigned char multiply(float *A[], int rowA, int colA, float *B[], int rowB, int colB, float *R[]);
unsigned char multiplyM(MATRIX, MATRIX, MATRIX *);

/*
 * 	This calculates transpose matrix of A
 */
unsigned char T(float *A[], int rowA, int colA, float *T[]);

/* make affine transformation */
unsigned char affineTransform(float m[4][4], float *p, float *R);
unsigned char affineTransformM(MATRIX , float P[], float R[]);

void translate(float tx, float ty, float tz, float *[]);
void translateM(float tx, float ty, float tz, MATRIX m);

void rotateX(float theta, float m[][4]);
void rotateY(float theta, float m[][4]);
void rotateZ(float theta, float m[][4]);
void rotate(float theta, POINT3D v, float m[][4]);
void rotate_1(float theta, float v[], float m[][4]);
void rotate_2(float theta, float vx, float vy, float yz, float m[][4]);
void rotateAboutArbitaryAxis(float theta, POINT3D A, POINT3D B, float m[][4]);

unsigned char scale(float sx, float sy, float sz, float *[]);
unsigned char shear(float xy, float yx, float xz, float zx, float yz, float zy, float *[]);
void reflectX(float *[]);
void reflectXM(MATRIX );
void reflectY(float *[]);
void reflectYM(MATRIX );
void reflectZ(float *[]);
void reflectZM(MATRIX );

#endif /* MYAFFINE_H_ */
